package com.app.micaihu.view.user.userinfo.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.micaihu.R;
import com.app.micaihu.app.AppApplication;
import com.app.micaihu.base.AppBaseAdapter;
import com.app.micaihu.bean.infor.AttentionAndFansBean;
import com.app.micaihu.bean.infor.BlacklistBean;
import com.app.micaihu.custom.view.CustomImageView;
import com.app.micaihu.manager.UserInforManager;
import com.app.micaihu.view.user.userinfo.DefriendView;
import com.app.utils.util.image.LoadImageUtils;

import java.util.List;

/**
 * Created by Guo on 2016/12/27.
 *
 *
 * 黑名单的适配器
 *
 *
 *
 */

public class BlacklistAdapter extends AppBaseAdapter<BlacklistBean> implements View.OnClickListener {
    public BlacklistAdapter(List<BlacklistBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View creatView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_blacklist, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        BlacklistBean blacklistBean = list.get(position);
        if(blacklistBean != null){
            if(blacklistBean.getVip()){
                viewHolder.ivVip.setVisibility(View.VISIBLE);
            }else{
                viewHolder.ivVip.setVisibility(View.GONE);
            }

            viewHolder.tvNickName.setText(blacklistBean.getNickName());

            if(TextUtils.isEmpty(blacklistBean.getSignature())){
                viewHolder.tvSignature.setText(AppApplication.getInstance().getString(R.string.user_signature));
            }else{
                viewHolder.tvSignature.setText(blacklistBean.getSignature());
            }

            LoadImageUtils.getInstance().loadListCircleImage(viewHolder.civHead,blacklistBean.getHeadPic());
            viewHolder.defriendView.setTag(blacklistBean);

        }

        return convertView;
    }

    @Override
    public void onClick(View v) {

    }


    class ViewHolder {
        CustomImageView civHead;
        TextView tvNickName;
        TextView tvSignature;
        View ivVip;
        DefriendView defriendView;

        ViewHolder(View convertView) {
            civHead = (CustomImageView) convertView.findViewById(R.id.civ_head);
            tvNickName = (TextView) convertView.findViewById(R.id.tv_nickname);
            tvSignature = (TextView) convertView.findViewById(R.id.tv_signature);
            ivVip = convertView.findViewById(R.id.iv_vip);
            defriendView = (DefriendView) convertView.findViewById(R.id.dv_defriend);

        }
    }




}
